﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdBrepRenderer : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdBrepRenderer(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdBrepRenderer obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdBrepRenderer()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdBrepRenderer(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public virtual void setBrep(OdBrBrep brep)
		{
			GlobalsPINVOKE.OdBrepRenderer_setBrep(this.swigCPtr, OdBrBrep.getCPtr(brep));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void enableCaching()
		{
			GlobalsPINVOKE.OdBrepRenderer_enableCaching(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void disableCaching(bool clearCache)
		{
			GlobalsPINVOKE.OdBrepRenderer_disableCaching__SWIG_0(this.swigCPtr, clearCache);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual void disableCaching()
		{
			GlobalsPINVOKE.OdBrepRenderer_disableCaching__SWIG_1(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual bool isCachingEnabled()
		{
			bool result = GlobalsPINVOKE.OdBrepRenderer_isCachingEnabled(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void setTriangulationParams(wrTriangulationParams pTriangulationParams)
		{
			GlobalsPINVOKE.OdBrepRenderer_setTriangulationParams(this.swigCPtr, wrTriangulationParams.getCPtr(pTriangulationParams));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public virtual wrTriangulationParams getTriangulationParams()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdBrepRenderer_getTriangulationParams(this.swigCPtr);
			wrTriangulationParams result = (intPtr == IntPtr.Zero) ? null : new wrTriangulationParams(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool draw(OdGiCommonDraw pWd, uint geomType, OdBrepRenderer.NumIsolines pNumIsolines)
		{
			bool result = GlobalsPINVOKE.OdBrepRenderer_draw__SWIG_0(this.swigCPtr, OdGiCommonDraw.getCPtr(pWd), geomType, OdBrepRenderer.NumIsolines.getCPtr(pNumIsolines));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool draw(OdGiCommonDraw pWd, uint geomType)
		{
			bool result = GlobalsPINVOKE.OdBrepRenderer_draw__SWIG_1(this.swigCPtr, OdGiCommonDraw.getCPtr(pWd), geomType);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool drawSilhouettes(OdGiViewportDraw pVd)
		{
			bool result = GlobalsPINVOKE.OdBrepRenderer_drawSilhouettes(this.swigCPtr, OdGiViewportDraw.getCPtr(pVd));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual void transformBy(OdGeMatrix3d xfm)
		{
			GlobalsPINVOKE.OdBrepRenderer_transformBy(this.swigCPtr, OdGeMatrix3d.getCPtr(xfm));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public const int kNothing = 0;

		public const int kIsolines = 1;

		public const int kEdges = 2;

		public const int kShells = 4;

		public const int kOrderedEdges = 8;

		public const int kSurfIsolines = 16;

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;

		public class NumIsolines : IDisposable
		{
			[EditorBrowsable(EditorBrowsableState.Never)]
			public NumIsolines(IntPtr cPtr, bool cMemoryOwn)
			{
				this.swigCMemOwn = cMemoryOwn;
				this.swigCPtr = new HandleRef(this, cPtr);
			}

			[EditorBrowsable(EditorBrowsableState.Never)]
			public static HandleRef getCPtr(OdBrepRenderer.NumIsolines obj)
			{
				if (obj != null)
				{
					return obj.swigCPtr;
				}
				return new HandleRef(null, IntPtr.Zero);
			}

			~NumIsolines()
			{
				this.Dispose();
			}

			public virtual void Dispose()
			{
				if (this.swigCPtr.Handle != IntPtr.Zero)
				{
					if (this.swigCMemOwn)
					{
						lock (this.locker)
						{
							if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
							{
								this.swigCMemOwn = false;
								GlobalsPINVOKE.delete_OdBrepRenderer_NumIsolines(this.swigCPtr);
							}
						}
						this.swigCMemOwn = false;
					}
					this.swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
			}

			public uint numU
			{
				get
				{
					uint result = GlobalsPINVOKE.OdBrepRenderer_NumIsolines_numU_get(this.swigCPtr);
					if (GlobalsPINVOKE.SWIGPendingException.Pending)
					{
						throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
					}
					return result;
				}
				set
				{
					GlobalsPINVOKE.OdBrepRenderer_NumIsolines_numU_set(this.swigCPtr, value);
					if (GlobalsPINVOKE.SWIGPendingException.Pending)
					{
						throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
					}
				}
			}

			public uint numV
			{
				get
				{
					uint result = GlobalsPINVOKE.OdBrepRenderer_NumIsolines_numV_get(this.swigCPtr);
					if (GlobalsPINVOKE.SWIGPendingException.Pending)
					{
						throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
					}
					return result;
				}
				set
				{
					GlobalsPINVOKE.OdBrepRenderer_NumIsolines_numV_set(this.swigCPtr, value);
					if (GlobalsPINVOKE.SWIGPendingException.Pending)
					{
						throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
					}
				}
			}

			public NumIsolines() : this(GlobalsPINVOKE.new_OdBrepRenderer_NumIsolines(), true)
			{
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}

			private object locker = new object();

			private HandleRef swigCPtr;

			protected bool swigCMemOwn;
		}
	}
}
